Repository navigation
fix(host-service): pin diff prefixes so user git config cannot break the Changes pane - #7652
sahiljagtap08 wants to merge 1 commit into
Conversation
…the Changes pane The Changes pane parses patch headers expecting a/ and b/ prefixes, but git derives those from user config. With diff.mnemonicPrefix or diff.noprefix set, the Staged, Unstaged, and untracked sections all render as Unable to load diff. Pin the four prefix settings with -c at every diff invocation. Unknown -c keys are ignored on old git versions, unlike --default-prefix which needs git 2.45. Fixes ParadevAI#7596
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change pins Git diff path prefixes to ChangesDiff prefix pinning
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~15 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The prefix handling is consistently applied across supported diff types, with isolated coverage for the affected Git configurations. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing: #7597 landed the same prefix pinning at the spawn seam, plus core.quotePath, and covers everything here. Thanks! |
Fixes #7596
What was broken
With
diff.mnemonicPrefix = true(ordiff.noprefix = true) in the user's gitconfig, every file under Staged and Unstaged shows "Unable to load diff". The sidebar counts are right, and Against base and Commits still work, which made this hard to diagnose.The pane parses patch text and expects
diff --git a/... b/...headers, but git builds those prefixes from user config. Mnemonic prefixes turn them intoi/andw/(unstaged),c/andi/(staged), and1/and2/(untracked via--no-index).diff.noprefixstrips them everywhere, which would break Against base and Commits too. Comparing two commits is the one case where mnemonic prefixes happen to matcha/andb/, which is exactly why those two sections kept working.The fix
Pin the four prefix settings at the invocation instead of teaching the parser every user's config. All five
git diffargv builders indiff-patch.tsnow start with:I used
-crather than--default-prefixon purpose:--default-prefixneeds git 2.45 and is a hard error below that, while unknown-ckeys are silently ignored by every git version, so this has no version floor.Tests
Three new tests in
diff-patch.test.tsagainst real git repos: withdiff.mnemonicPrefix, withdiff.noprefix, and with customsrcPrefix/dstPrefix, the unstaged, staged, and untracked patches must all keepa/andb/headers. All three fail on main.Out of scope
The issue also notes that the Retry button on the placeholder never refetches, and a possible quoting mismatch for non-ASCII filenames. Both are renderer concerns and worth their own issues; this PR fixes the reason the placeholder appears in the first place.
Summary by cubic
Fixes the Changes pane rendering "Unable to load diff" when user git config sets
diff.mnemonicPrefix,diff.noprefix, or customsrcPrefix/dstPrefix, by pinning the prefix settings at every git diff invocation.diff.mnemonicPrefix,diff.noprefix,diff.srcPrefix, anddiff.dstPrefixwith-cflags in all five diff argument builders indiff-patch.ts.-cinstead of--default-prefixso there's no git version floor; unknown-ckeys are ignored by older git.noprefix, and custom prefixes, all of which fail on main.Out of scope
Written for commit 572003b. Summary will update on new commits.
Summary by CodeRabbit
a/andb/headers instead of appearing as unavailable.